package main

import (
	"fmt"
	"reflect"
)

type Person struct {
	Name string
	Age  int
}

func main() {
	p := Person{Name: "Alice", Age: 25}
	fmt.Println("Before:", p)

	// 使用反射获取结构体指针，并修改属性值
	v := reflect.ValueOf(&p).Elem()
	t := v.Type()

	Age, _ := t.FieldByName("Age")
	Age.Type.El

	for i := 0; i < t.NumField(); i++ {
		field := t.Field(i)
		value := v.Field(i)
		switch field.Name {
		case "Name":
			value.SetString("Bob")
		case "Age":
			value.SetInt(30)
		}
	}

	fmt.Println("After:", p)
}
